package com.whisperarts.financer.app.editors;

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

import com.whisperarts.financer.model.account.Account;

public class AccountEditorInput implements IEditorInput {

	private final Account account;

	public AccountEditorInput(Account account) {
		super();
		Assert.isNotNull(account);
		this.account = account;
	}

	@Override
	public Object getAdapter(Class adapter) {
		return null;
	}

	@Override
	public boolean exists() {
		return false;
	}

	@Override
	public ImageDescriptor getImageDescriptor() {
		return null;
	}

	@Override
	public String getName() {
		return account.getName();
	}
	
	public Account getAccount() {
		return account;
	}

	@Override
	public IPersistableElement getPersistable() {
		return null;
	}

	@Override
	public String getToolTipText() {
		return account.getName();
	}

	@Override
	public boolean equals(Object obj) {
		if (super.equals(obj))
			return true;
		if (!(obj instanceof AccountEditorInput))
			return false;
		AccountEditorInput other = (AccountEditorInput) obj;
		return account.equals(other.account);
	}

	@Override
	public int hashCode() {
		return account.hashCode();
	}


}
